package com.xc.xcrpc.fault.tolerant;

import com.xc.xcrpc.fault.retry.NoRetryStrategy;
import com.xc.xcrpc.fault.retry.RetryStrategy;
import com.xc.xcrpc.spi.SpiLoader;

/**
 * 容错策略工厂（工厂模式，用于获取容错机制对象）
 * @author zqx
 * @since 2024/10/1
 */
public class TolerantStrategyFactory {


    static {
        SpiLoader.load(TolerantStrategy.class);
    }

    /**
     * 默认重试器
     */
    private static final TolerantStrategy DEFAULT_RETRY_STRATEGY = new FailFastTolerantStrategy();

    /**
     * 获取实例
     */
    public static TolerantStrategy getInstance(String key){
        return SpiLoader.getInstance(TolerantStrategy.class,key);
    }

}
